package com.fifth.order.controller.api;

import com.fifth.order.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @作者：刘壬杉
 * @创建时间 2022/9/22 10:21
 **/
@RestController
@RequestMapping("api/stock")
public class ApiStockController {
    @Autowired
    private StockService stockService;

    /**
     * 修改库存
     * @param id
     * @param sellnum
     * @param totalnum
     */
    @PostMapping("updateStock/{id}/{sellnum}/{totalnum}")
    public void updateStock(@PathVariable Integer id, @PathVariable Integer sellnum, @PathVariable Integer totalnum){
         stockService.updateStock(id,sellnum,totalnum);
    }

    /**
     * 添加库存
     * @param id
     * @param sellnum
     * @param totalnum
     */
    @PostMapping("addStock/{id}/{totalnum}/{price}")
    public void addStock(@PathVariable Integer id, @PathVariable Integer totalnum, @PathVariable Integer price){
         stockService.addStock(id,totalnum,price);
    }




}
